import cn.hutool.core.util.ArrayUtil;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;

public class CodeTest {

    @Test
    public void test5() {
        //[A07, A07A01, A07A01A01, A07A01A01A03, A07A01A01A03A02, A07A01A01A03A02A08, A07A01A01A03A02A08A03]
        String test = "A07A01A01A03A02A08A03";
        test.split("");
        List strs = new ArrayList();
        strs.toArray(new Double[0]);

        int z = 0;
        for(int i=0;i<test.length()/3;i++){
            String a = test.substring(z,z+3);
            strs.add(a);
            z = z+3;
        }
        List returnStrs = new ArrayList();
        StringBuffer str = new StringBuffer();
        strs.forEach(x->{
            StringBuffer append = str.append(x);
            returnStrs.add(append.toString());
        });
        System.out.println(returnStrs);
    }
    @Test
    public void test() {
        String[] str = new String[]{"A01", "A01A03A01", "A01A02"};
        List<String> strings = Arrays.asList(str);
        String join = ArrayUtil.join(strings.toArray(), ".*|") + ".*";
        //数据集合的
        String db = "A01A01.*|A01A02.*|A01A03A01.*|A01A03A02.*";
        //传入的code集合
        boolean isMatch = Pattern.matches(db, "A01A03A01A01A02");
        boolean isMatch2 = Pattern.matches(db, "A01A03A01A01");
        boolean isMatch3 = Pattern.matches(db, "A01A03A01");
        boolean isMatch4 = Pattern.matches(db, "A01");
        boolean isMatch5 = Pattern.matches(db, "A01A03");
        System.out.println(isMatch);
    }


//    sql like in  sql查询 示例
//    REGEXP + GROUP_CONCAT(val separator '|')


//    select
//      distinct community.id,
//      community.name,
//      community.code
//    from
//      sys_area_administrative community
//    where
//    community.area_type = '90170002'
//    and community.`code` REGEXP (
//            SELECT
//                    GROUP_CONCAT(a.area_code separator '|')
//            from sys_depart_area a
//            where a.sys_org_code in
//					<foreach collection="orgcodes" item="orgcode" close=")" open="(" separator=",">
//                          #{orgcode}
//					</foreach>
//            )
//			<if test="name !=null and name !=''">
//             and community.name like concat('%',#{name},'%')
//			</if>

//    and area.area_code in (
//            SELECT
//                    sysarea.`code`
//                    from
//                    sys_area_administrative sysarea
//                    where
//                    sysarea.`code` REGEXP (#{areas})
//            )


//    SELECT 'Hern' REGEXP '[0-9]';
}
